<template>
	<view class="content">
		<view class="title">
			<text style="color: black;">子组件B</text>
		</view>
		<view class="b-box">
			CompA组件传进来的值:
			<text class="intent-text-box">{{result}}</text>
		</view>
		<view class="b-box row-layout">
			<text>回传值: </text>
			<input  type="text" v-model="callbackValue" style="color: yellow; background-color: #cccccc;"/>
			<button @click="sendOutside()">回传</button>
		</view>
	</view>
</template>

<script>
	export default {
		name: "compB",
		data() {
			return {
				result: '',
				callbackValue: '0595-2788888'
			};
		},
		created() {
			uni.$on('getIntent', (msg) => {
				console.error("----CompB----getIntent----->" + msg);
				this.result = msg;
			});
		},
		methods: {
			sendOutside() {
				console.warn("----CompB-----sendOutside----->" + this.callbackValue);
				this.$emit('callBackFun', this.callbackValue);
			}
		}
	}
</script>

<style>
	.content {
			height: 120px;
			margin: 10px 0;
			padding: 15px;
			background-color: #4cd964;
			border-radius: 8px;
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: space-around;
		}
	.title{
		font-size: 18px;
		font-weight: bold;
		color: #fff;
		text-align: center;
	}
	.b-box{
		font-size: 14px;
		color: #333;

	}
	.intent-text-box{
		background-color: blue;
		color: #fff;
		padding: 2px 8px;
		border-radius: 4px;
		margin-left: 5px;
	}
	.row-layout{
		display: flex;
		align-items: center;
		gap: 8px;
	}
	
</style>